<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>快速开始 | 美的楼宇科技研究院</title>
    <meta name="generator" content="VuePress 1.9.5">
    <link rel="icon" href="/img/favicon.ico">
    <meta name="description" content="iBUILDING作为智慧建筑的数字践行者，致力于用数字的眼光建筑世界。以科技赋能楼宇，构建数字建筑生态，共创更美好的智慧空间。Make iBUILDING come TRUE。">
    <meta name="keywords" content="iBUILDING,ibuilding">
    <meta name="theme-color" content="#11a8cd">
    <meta name="baidu-site-verification" content="code-j1XZ46JIBR">
    
    <link rel="preload" href="/assets/css/0.styles.af9b49f9.css" as="style"><link rel="preload" href="/assets/js/app.ffe9b366.js" as="script"><link rel="preload" href="/assets/js/2.9760a328.js" as="script"><link rel="preload" href="/assets/js/15.752b1e82.js" as="script"><link rel="prefetch" href="/assets/js/10.1ca8e9a5.js"><link rel="prefetch" href="/assets/js/11.f84ca260.js"><link rel="prefetch" href="/assets/js/12.5d62fb57.js"><link rel="prefetch" href="/assets/js/13.3fd35f26.js"><link rel="prefetch" href="/assets/js/14.d428d44b.js"><link rel="prefetch" href="/assets/js/16.f33da816.js"><link rel="prefetch" href="/assets/js/17.4a25f92e.js"><link rel="prefetch" href="/assets/js/18.3ad538ff.js"><link rel="prefetch" href="/assets/js/19.4957cef9.js"><link rel="prefetch" href="/assets/js/20.264d8716.js"><link rel="prefetch" href="/assets/js/21.2e6c7b77.js"><link rel="prefetch" href="/assets/js/22.4abc22b5.js"><link rel="prefetch" href="/assets/js/23.52e85444.js"><link rel="prefetch" href="/assets/js/24.ae24e643.js"><link rel="prefetch" href="/assets/js/25.5596a9ad.js"><link rel="prefetch" href="/assets/js/26.d952969d.js"><link rel="prefetch" href="/assets/js/27.7711bd91.js"><link rel="prefetch" href="/assets/js/3.0b2e2ac4.js"><link rel="prefetch" href="/assets/js/4.d41f70ee.js"><link rel="prefetch" href="/assets/js/5.603be3f5.js"><link rel="prefetch" href="/assets/js/6.36f53e66.js"><link rel="prefetch" href="/assets/js/7.8566b5df.js"><link rel="prefetch" href="/assets/js/8.82830ba8.js"><link rel="prefetch" href="/assets/js/9.d949e13c.js">
    <link rel="stylesheet" href="/assets/css/0.styles.af9b49f9.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="https://static-btri.midea.com/mfs/1001/1656483801940.svg" alt="美的楼宇科技研究院" class="logo"> <span class="site-name can-hide">美的楼宇科技研究院</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="📖开源项目" class="dropdown-title"><!----> <span class="title" style="display:;">📖开源项目</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/driver-box/" class="nav-link router-link-active">driver-box</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="开发者社区" class="dropdown-title"><!----> <span class="title" style="display:;">开发者社区</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/blog/about.html" class="nav-link">技术博客</a></li><li class="dropdown-item"><!----> <a href="https://openibuilding.midea.com/home" target="_blank" rel="noopener noreferrer" class="nav-link external">
  开放平台
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="开源仓库" class="dropdown-title"><!----> <span class="title" style="display:;">开源仓库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://gitee.com/iBUILDING-X" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><!----> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="📖开源项目" class="dropdown-title"><!----> <span class="title" style="display:;">📖开源项目</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/driver-box/" class="nav-link router-link-active">driver-box</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="开发者社区" class="dropdown-title"><!----> <span class="title" style="display:;">开发者社区</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/blog/about.html" class="nav-link">技术博客</a></li><li class="dropdown-item"><!----> <a href="https://openibuilding.midea.com/home" target="_blank" rel="noopener noreferrer" class="nav-link external">
  开放平台
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="开源仓库" class="dropdown-title"><!----> <span class="title" style="display:;">开源仓库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://gitee.com/iBUILDING-X" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><a href="/driver-box/" aria-current="page" class="sidebar-link">driver-box</a></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>用户手册</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/driver-box/quick_start/" aria-current="page" class="active sidebar-link">快速开始</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level2"><a href="/driver-box/quick_start/#环境准备" class="sidebar-link">环境准备</a></li><li class="sidebar-sub-header level2"><a href="/driver-box/quick_start/#使用步骤" class="sidebar-link">使用步骤</a></li></ul></li><li><a href="/driver-box/guides/config/" class="sidebar-link">配置说明</a></li><li><a href="/pages/8e66ec/" class="sidebar-link">HTTP Client 插件</a></li><li><a href="/pages/3162cd/" class="sidebar-link">HTTP Server 插件</a></li><li><a href="/pages/f8d682/" class="sidebar-link">Modbus 插件</a></li><li><a href="/pages/4fcadc/" class="sidebar-link">BACnet 插件</a></li><li><a href="/pages/417ad9/" class="sidebar-link">MQTT 插件</a></li><li><a href="/pages/312d09/" class="sidebar-link">TCP Server 插件</a></li><li><a href="/pages/28a924/" class="sidebar-link">脚本内置模块</a></li><li><a href="/pages/da9d86/" class="sidebar-link">RESTful API</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>开发者手册</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/driver-box/dev/compile_run/" class="sidebar-link">编译运行</a></li><li><a href="/driver-box/dev/release/" class="sidebar-link">发版记录</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>设计思路</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pages/design/concept/" class="sidebar-link">相关概念</a></li><li><a href="/pages/design/structure/" class="sidebar-link">系统架构</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>设备实战</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pages/674f6d/" class="sidebar-link">厕所门把手</a></li></ul></section></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-06225672><div class="articleInfo" data-v-06225672><ul class="breadcrumbs" data-v-06225672><li data-v-06225672><a href="/" title="首页" class="iconfont icon-home router-link-active" data-v-06225672></a></li> <li data-v-06225672><span data-v-06225672>driver-box</span></li><li data-v-06225672><span data-v-06225672>用户手册</span></li></ul> <div class="info" data-v-06225672><div title="作者" class="author iconfont icon-touxiang" data-v-06225672><a href="javascript:;" data-v-06225672>爱丁</a></div> <div title="创建时间" class="date iconfont icon-riqi" data-v-06225672><a href="javascript:;" data-v-06225672>2023-03-14</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-title">目录</div> <div class="right-menu-content"></div></div></div> <h1><img src="">快速开始<!----></h1> <div class="page-slot page-slot-top">
    <div class="wwads-cn wwads-horizontal page-wwads" data-id="136"></div>
    <style>
      .page-wwads{
        width:100%!important;
        min-height: 0;
        margin: 0;
      }
      .page-wwads .wwads-img img{
        width:80px!important;
      }
      .page-wwads .wwads-poweredby{
        width: 40px;
        position: absolute;
        right: 25px;
        bottom: 3px;
      }
      .wwads-content .wwads-text, .page-wwads .wwads-text{
        height: 100%;
        padding-top: 5px;
        display: block;
      }
  </style>
  </div> <div class="theme-vdoing-content content__default"><h1 id="快速开始"><a href="#快速开始" class="header-anchor">#</a> 快速开始</h1> <p>本文将通过一个简单的示例，来讲述如何快速接入一个通信协议为 http 的设备。</p> <h2 id="环境准备"><a href="#环境准备" class="header-anchor">#</a> 环境准备</h2> <p>Linux、Windows、Mac 均可</p> <h2 id="使用步骤"><a href="#使用步骤" class="header-anchor">#</a> 使用步骤</h2> <ol><li><p>下载<a href="https://gitee.com/iBUILDING-X/driver-box/releases/" target="_blank" rel="noopener noreferrer">发行包<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> ，现支持架构包括：</p> <ul><li>Windows：amd64、arm64</li> <li>Linux：amd64、arm64</li> <li>Mac：amd64、arm64</li></ul></li> <li><p>解压发行包。(Windows环境为zip包)</p></li></ol> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">tar</span> xvf driver-box-<span class="token operator">&lt;</span>os<span class="token operator">&gt;</span>-<span class="token operator">&lt;</span>arch<span class="token operator">&gt;</span>.tar
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ol start="3"><li>启动 driver-box</li></ol> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>./driver-box <span class="token parameter variable">-broker</span><span class="token operator">=</span>mqtt://82.157.162.230:1883 <span class="token parameter variable">-clientId</span><span class="token operator">=</span><span class="token number">123456</span> <span class="token parameter variable">-exportTopic</span><span class="token operator">=</span>/driverbox/export/
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ol start="4"><li><p>启动 MQTTX 客户端，充当物联网云平台的角色。并订阅topic：<code>/driverbox/export/</code></p></li> <li><p>发送模拟请求<br>
我们已预先配置了一个使用 HttpServer 插件的设备，以方便快速上手。
该设备为一个传感器设备，仅一个开关点位，可通过 HTTP 请求模拟设备点位变化。</p></li></ol> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 模拟 “开”</span>
<span class="token function">curl</span> http://localhost:8080/sensorModel/sensor_1/on

<span class="token comment"># 模拟 关“”</span>
<span class="token function">curl</span> http://localhost:8080/sensorModel/sensor_1/off
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><ol start="6"><li>观察 MQTTX 客户端接收到的报文.</li></ol> <div class="language-json line-numbers-mode"><pre class="language-json"><code>topic<span class="token operator">:</span> /driverbox/export/
payload<span class="token operator">:</span> <span class="token punctuation">{</span><span class="token property">&quot;device_name&quot;</span><span class="token operator">:</span><span class="token string">&quot;sensor_1&quot;</span><span class="token punctuation">,</span><span class="token property">&quot;values&quot;</span><span class="token operator">:</span><span class="token punctuation">[</span><span class="token punctuation">{</span><span class="token property">&quot;name&quot;</span><span class="token operator">:</span><span class="token string">&quot;onOff&quot;</span><span class="token punctuation">,</span><span class="token property">&quot;type&quot;</span><span class="token operator">:</span><span class="token string">&quot;&quot;</span><span class="token punctuation">,</span><span class="token property">&quot;value&quot;</span><span class="token operator">:</span><span class="token number">1</span><span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">}</span>

topic<span class="token operator">:</span> /driverbox/export/
payload<span class="token operator">:</span> <span class="token punctuation">{</span><span class="token property">&quot;device_name&quot;</span><span class="token operator">:</span><span class="token string">&quot;sensor_1&quot;</span><span class="token punctuation">,</span><span class="token property">&quot;values&quot;</span><span class="token operator">:</span><span class="token punctuation">[</span><span class="token punctuation">{</span><span class="token property">&quot;name&quot;</span><span class="token operator">:</span><span class="token string">&quot;onOff&quot;</span><span class="token punctuation">,</span><span class="token property">&quot;type&quot;</span><span class="token operator">:</span><span class="token string">&quot;&quot;</span><span class="token punctuation">,</span><span class="token property">&quot;value&quot;</span><span class="token operator">:</span><span class="token number">0</span><span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><div class="custom-block tip"><p class="custom-block-title">提示</p> <p>如果用浏览器发送的请求，可能会收到两个报文。
因为脚本逻辑不够严谨，浏览器发送的<code>/favicon.ico</code>请求命中<code>on</code>条件。</p></div></div></div>  <div class="page-edit"><!----> <!----> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2023/08/01, 15:39:47</span></div></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/driver-box/" class="page-nav-centre page-nav-centre-prev router-link-active"><div class="tooltip">driver-box</div></a> <a href="/driver-box/guides/config/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">配置说明</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/driver-box/" class="prev router-link-active">driver-box</a></span> <span class="next"><a href="/driver-box/guides/config/">配置说明</a>→
      </span></p></div></div></div> <!----></main></div> <div class="footer"><div class="icons"><a href="https://gitee.com/iBUILDING-X" title="Gitee" target="_blank" class="iconfont icon-gitee"></a></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2023-2023
    <span>iBUILDING</span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"></div></div>
    <script src="/assets/js/app.ffe9b366.js" defer></script><script src="/assets/js/2.9760a328.js" defer></script><script src="/assets/js/15.752b1e82.js" defer></script>
  </body>
</html>
